package com.dept.controller;

import com.common.compoent.PrintWriter;
import com.common.pojo.Dept;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Str
 * @Date 2022/1/6 14:21
 * @Description :
 */
@RequestMapping("/dept")
@RestController
public class DeptController {
    // 引入配置文件中的端口
    @Value("${server.port}")
    private String port;

    @GetMapping("/getDeptById")
    public Dept getDeptById(@RequestParam("id") Integer id){
        PrintWriter.prtMark("DeptController.getDeptById.id："+id);
        PrintWriter.prtMark("port："+port);
        return new Dept(id,"top","top_1","本部",port,"1","高级");
    }

    @GetMapping("/getLongTime")
    public String getLongTime(){
        long startTime =  System.currentTimeMillis();
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        long endTime =  System.currentTimeMillis();
        return "消耗时间："+(endTime-startTime)+"ms";
    }

    @GetMapping("/getShortTime")
    public String getShortTime(){
        long startTime =  System.currentTimeMillis();
        long endTime =  System.currentTimeMillis();
        return "消耗时间："+(endTime-startTime)+"ms";
    }
}
